import { Injectable, Logger } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { ConfigService } from '@nestjs/config';
import { BaseService } from '@wwjCommon/base/base.service';
import { CacheService } from '@wwjCommon/cache/cache.service';
import { LoggingService } from '@wwjCommon/logging/logging.service';
import { UploadService } from '@wwjVendor/upload/upload.service';
import { PayService } from '@wwjVendor/pay/pay.service';
import { SmsService } from '@wwjVendor/sms/sms.service';
import { NoticeService } from '@wwjVendor/notice/notice.service';

@Injectable()
export class CoreUploadConfigService extends BaseService<any> {
  private readonly logger = new Logger(CoreUploadConfigService.name);

  constructor(
    @InjectRepository(Object)
    protected readonly repository: Repository<any>,
    private readonly cacheService: CacheService,
    private readonly configService: ConfigService,
    private readonly loggingService: LoggingService,
    private readonly uploadService: UploadService,
    private readonly payService: PayService,
    private readonly smsService: SmsService,
    private readonly noticeService: NoticeService,
  ) {
    super(repository);
  }

  /**
   * getUploadConfig
   * 对应 PHP: CoreUploadConfigService_core::getUploadConfig()
   * 逻辑类型: undefined - undefined
   */
  async getUploadConfig(site_id: number) {
    // 基于PHP真实逻辑: getUploadConfig
    // PHP原文: $info = (new  CoreConfigService())->getConfig($site_id, ConfigKeyDict::UPLOAD)['value'] ?? [];         if (empty($info)) {             $info = [      ...
const info = this.coreConfigService.getConfig(site_id, ConfigKeyDict.UPLOAD).value || [];
        if (!info)) {
            const info = [
                image_ext: [
                    'jpg', 'png', 'gif', 'jpeg' // todo 暂不支持webp格式
                ],//图片上传文件后缀
                video_ext: [
                    'wmv', 'avi', 'mpg', 'mpeg', '3gp', 'mov', 'mp4', 'flv', 'f4v', 'rmvb', 'mkv'
                ],//视频上传文件后缀
                document_ext: [
                    'crt', 'pem'
                ],
                image_size: 0,//图片上传大小限制
                video_size: 0,//视频上传大小限制
                document_size: 0,//文件上传大小限制
            ];
  }

  /**
   * setUploadConfig
   * 对应 PHP: CoreUploadConfigService_core::setUploadConfig()
   * 逻辑类型: undefined - undefined
   */
  async setUploadConfig(site_id: any[], data: any[]) {
    // 基于PHP真实逻辑: setUploadConfig
    // PHP原文: return (new  CoreConfigService())->setConfig($site_id, ConfigKeyDict::UPLOAD, $data);      }  }...
return this.coreConfigService.setConfig(site_id, ConfigKeyDict.UPLOAD, data);

    }

}
  }
}
